package com.chinacoal.microservice.api;

import java.util.List;

import javax.validation.Valid;

import org.springframework.cloud.openfeign.FeignAutoConfiguration;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import com.baomidou.mybatisplus.plugins.Page;
import com.chinacoal.microservice.api.fallback.WorkflowClientFallback;
import com.chinacoal.microservice.model.wofkflow.ApproveParam;
import com.chinacoal.microservice.model.wofkflow.QueryTaskListParam;
import com.chinacoal.microservice.model.wofkflow.SubmitParam;
import com.chinacoal.microservice.model.wofkflow.entity.ApprovalHistoryEntity;
import com.chinacoal.microservice.model.wofkflow.entity.InstanceEntity;
import com.chinacoal.microservice.model.wofkflow.entity.WorkItemEntity;
import com.chinacoal.microservice.util.result.Result;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

/**  
 * @Package: com.chinacoal.microservice.api.WorkflowClient
 * @ClassName: WorkflowClient
 * @ClassDesc: 工作流管理Client
 * @Createby: sunh
 * @CreatedDate: 2019-11-28 21:37:41
 */  
@Api(tags={"流程引擎对外服务接口"})
@FeignClient(name = "ccms-workflow", configuration = FeignAutoConfiguration.class, fallback = WorkflowClientFallback.class)
public interface WorkflowClient {
	
    /**  
     * @Package: com.chinacoal.microservice.api.WorkflowClient.processSubmit
     * @MethodName: processSubmit
     * @MethodDesc: 提交并启动流程
     * @ParamList: {
     *				 @param submitParam
     *			   }
     * @Return: Result<InstanceEntity>
     * @Createby: sunh
     * @CreatedDate: 2019-12-02 10:40:51
     */ 
    @ApiOperation(value = "提交流程")
    @PostMapping("/workflow/processSubmit")
    public Result<InstanceEntity> processSubmit(@Valid @RequestBody SubmitParam submitParam);

    /**  
     * @Package: com.chinacoal.microservice.api.WorkflowClient.completeTask
     * @MethodName: completeTask
     * @MethodDesc: 完成待办
     * @ParamList: {
     *				 @param approveModal
     *			   }
     * @Return: Result<InstanceEntity>
     * @Createby: sunh
     * @CreatedDate: 2019-12-02 10:41:11
     */ 
    @ApiOperation(value = "审批待办")
    @PostMapping("/workflow/completeTask")
    public Result<InstanceEntity> completeTask(@Valid @RequestBody ApproveParam approveModal);
    
    /**  
     * @Package: com.chinacoal.microservice.api.WorkflowClient.deleteInstanceById
     * @MethodName: deleteInstanceById
     * @MethodDesc: 根据实例id删除流程实例
     * @ParamList: {
     *				 @param instanceIds
     *			   }
     * @Return: Result<Object>
     * @Createby: sunh
     * @CreatedDate: 2019-12-02 10:41:21
     */ 
    @ApiOperation(value = "根据流程实例ID删除流程实例")
    @PostMapping("/workflow/deleteInstanceById")
    public Result<Object> deleteInstanceById(@RequestBody List<Long> instanceIds);
    
    /**  
     * @Package: com.chinacoal.microservice.api.WorkflowClient.getTaskList
     * @MethodName: getTaskList
     * @MethodDesc: 获取待办列表
     * @ParamList: {
     *				 @param page
     *				 @param pageSize
     *				 @param queryParam
     *			   }
     * @Return: Result<Page<WorkItemEntity>>
     * @Createby: sunh
     * @CreatedDate: 2019-12-02 10:41:53
     */ 
    @ApiOperation(value = "查询当前登录用户的待办列表")
    @ApiImplicitParams({
        @ApiImplicitParam(paramType="path", name = "page", value = "当前页码", required = true, dataType = "int"),
        @ApiImplicitParam(paramType="path", name = "pageSize", value = "每页记录数", required = true, dataType = "int")
    })
    @PostMapping("/workflow/getTaskList/{page}/{pageSize}")
    public Result<Page<WorkItemEntity>> getTaskList(@PathVariable("page") Integer page,
    											    @PathVariable("pageSize") Integer pageSize,
    											    @Valid @RequestBody QueryTaskListParam queryParam);
    
    /**  
     * @Package: com.chinacoal.microservice.api.WorkflowClient.getAchTaskList
     * @MethodName: getAchTaskList
     * @MethodDesc: 获取已办列表
     * @ParamList: {
     *				 @param page
     *				 @param pageSize
     *				 @param queryParam
     *			   }
     * @Return: Result<Page<WorkItemEntity>>
     * @Createby: sunh
     * @CreatedDate: 2019-12-02 10:42:10
     */ 
    @ApiOperation(value = "查询当前登录用户的已办列表")
    @ApiImplicitParams({
        @ApiImplicitParam(paramType="path", name = "page", value = "当前页码", required = true, dataType = "int"),
        @ApiImplicitParam(paramType="path", name = "pageSize", value = "每页记录数", required = true, dataType = "int")
    })
    @PostMapping("/workflow/getAchTaskList/{page}/{pageSize}")
    public Result<Page<WorkItemEntity>> getAchTaskList(@PathVariable("page") Integer page,
													   @PathVariable("pageSize") Integer pageSize,
													   @Valid @RequestBody QueryTaskListParam queryParam);
    
    /**  
     * @Package: com.chinacoal.microservice.api.WorkflowClient.getApprovalHistory
     * @MethodName: getApprovalHistory
     * @MethodDesc: 获取审批历史列表
     * @ParamList: {
     *				 @param page
     *				 @param pageSize
     *				 @param instanceId
     *			   }
     * @Return: Result<Page<ApprovalHistoryEntity>>
     * @Createby: sunh
     * @CreatedDate: 2019-12-02 11:02:02
     */ 
    @ApiOperation(value = "按流程实例ID查询审批历史")
    @ApiImplicitParams({
        @ApiImplicitParam(paramType="path", name = "instanceId", value = "实例id", required = true, dataType = "Long"),
    	@ApiImplicitParam(paramType="path", name = "page", value = "当前页码", required = true, dataType = "int"),
    	@ApiImplicitParam(paramType="path", name = "pageSize", value = "每页记录数", required = true, dataType = "int")
    })
    @GetMapping("/workflow/approvalHistory/{instanceId}/{page}/{pageSize}")
    public Result<Page<ApprovalHistoryEntity>> getApprovalHistory(@PathVariable("page") Integer page,
    															  @PathVariable("pageSize") Integer pageSize,
    															  @PathVariable("instanceId") Long instanceId);
}
